window: Update popover positions on ::size-allocate
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 1 Aug 2014 15:38:42 +0000 (17:38 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Sun, 3 Aug 2014 16:37:53 +0000 (18:37 +0200)
Popovers may get relocations optimized away if only x/y changed
in the GtkAllocation. So make sure the toplevel updates popover
positions on all situations.

https://bugzilla.gnome.org/show_bug.cgi?id=729140

gtk/Makefile.am
gtk/gtkpopover.c
gtk/gtkpopoverprivate.h [new file with mode: 0644]
gtk/gtkwindow.c

index e9d01ee0ef26d9bb87b62339cf31aa64f38fac54..6c4632eb075a91c15dd8635c4b928f9dcb819c52 100644 (file)
@@ -625,6 +625,7 @@ gtk_private_h_sources =             \
        gtkorientableprivate.h  \
        gtkpango.h              \
        gtkpathbar.h            \
+       gtkpopoverprivate.h     \
        gtkprintoperation-private.h \
        gtkprintutils.h         \
        gtkprivate.h            \
index b660a904b4e40d0de6ef63465035acd4aff6ef09..0acb1337b91d0cc54507fc60fd820fe1b49bab33 100644 (file)
@@ -78,6 +78,7 @@
 #include <gdk/gdk.h>
 #include <cairo-gobject.h>
 #include "gtkpopover.h"
+#include "gtkpopoverprivate.h"
 #include "gtktypebuiltins.h"
 #include "gtkmain.h"
 #include "gtkwindowprivate.h"
@@ -143,7 +144,6 @@ struct _GtkPopoverPrivate
 static GQuark quark_widget_popovers = 0;
 static guint signals[N_SIGNALS] = { 0 };
 
-static void gtk_popover_update_position    (GtkPopover *popover);
 static void gtk_popover_update_relative_to (GtkPopover *popover,
                                             GtkWidget  *relative_to);
 
@@ -761,7 +761,7 @@ opposite_position (GtkPositionType pos)
     }
 }
 
-static void
+void
 gtk_popover_update_position (GtkPopover *popover)
 {
   GtkPopoverPrivate *priv = popover->priv;
diff --git a/gtk/gtkpopoverprivate.h b/gtk/gtkpopoverprivate.h
new file mode 100644 (file)
index 0000000..ab61eb9
--- /dev/null
@@ -0,0 +1,29 @@
+/* GTK - The GIMP Toolkit
+ * Copyright © 2014 Carlos Garnacho <carlosg@gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_POPOVER_PRIVATE_H__
+#define __GTK_POPOVER_PRIVATE_H__
+
+#include "gtkpopover.h"
+
+G_BEGIN_DECLS
+
+void gtk_popover_update_position (GtkPopover *popover);
+
+G_END_DECLS
+
+#endif /* __GTK_POPOVER_PRIVATE_H__ */
index e7b336b201c90b465f8482846f0c5c0edd84f1fa..4da45b069435f832e2f51bfe423c845f6216969d 100644 (file)
@@ -56,6 +56,7 @@
 #include "gtkbutton.h"
 #include "gtkheaderbar.h"
 #include "gtkheaderbarprivate.h"
+#include "gtkpopoverprivate.h"
 #include "a11y/gtkwindowaccessible.h"
 #include "a11y/gtkcontaineraccessibleprivate.h"
 #include "gtkapplicationprivate.h"
@@ -7165,6 +7166,9 @@ popover_size_allocate (GtkWidget        *widget,
   if (!popover->window)
     return;
 
+  if (GTK_IS_POPOVER (popover->widget))
+    gtk_popover_update_position (GTK_POPOVER (popover->widget));
+
   popover_get_rect (popover, window, &rect);
   gdk_window_move_resize (popover->window, rect.x, rect.y,
                           rect.width, rect.height);